home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Mousebroken 1.0.1 / source / Modules source ƒ / Unhelpful mouse / Unhelpful module.c next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.6 KB  |  85 lines  |  [TEXT/KAHL]

  1. /* Unhelpful mouse -- a Mousebroken mouse module */
  2. /* written 11/93 by Mark Pilgrim */
  3. /* This module placed in the public domain. */
  4.  
  5. #include "Retrace.h"
  6. #include "GestaltEQU.h"
  7.  
  8. extern Boolean CrsrNew : 0x8CE;
  9. extern Point mTemp : 0x828;
  10. extern Point RawMouse : 0x82C;
  11.  
  12. Rect            gMainScreenBounds;
  13. unsigned long    me;
  14. Rect            helpRect;
  15. int                oldX,oldY;
  16.  
  17. #define LEFTSIDE        -69
  18. #define RIGHTSIDE        -37
  19. #define TOPSIDE            0
  20. #define BOTTOMSIDE        MBarHeight+2
  21.  
  22. void header(void);
  23. void main(void);
  24.  
  25. void header(void)
  26. {
  27.     asm
  28.     {
  29.         dc.l    0
  30.         move.l a0, d0
  31.         lea header, a0
  32.         jmp main
  33.     }
  34. }
  35.  
  36. #include "SetUpA4.h"
  37.  
  38. void main(void)
  39. {
  40.     VBLTask*        myVBL;
  41.     long            gestalt_temp;
  42.     OSErr            isHuman;
  43.     Boolean            isDormant;
  44.     
  45.     RememberA0();
  46.     SetUpA4();
  47.     
  48.     asm
  49.     {
  50.         move.l d0, myVBL
  51.     }
  52.     
  53.     if (me != 'MMdl')
  54.     {
  55.         isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);
  56.         gMainScreenBounds=(isHuman || (gestalt_temp < gestalt8BitQD)) ? screenBits.bounds :
  57.             (**GetMainDevice()).gdRect;
  58.         me = 'MMdl';
  59.         SetRect(&helpRect, gMainScreenBounds.right+LEFTSIDE,
  60.                             gMainScreenBounds.top+TOPSIDE,
  61.                             gMainScreenBounds.right+RIGHTSIDE,
  62.                             gMainScreenBounds.top+BOTTOMSIDE);
  63.         OffsetRect(&helpRect, gMainScreenBounds.left, gMainScreenBounds.top);
  64.         oldX=RawMouse.h;
  65.         oldY=RawMouse.v;
  66.     }
  67.     
  68.     if (PtInRect(RawMouse, &helpRect))
  69.     {
  70.         if (oldX<=helpRect.left)
  71.             RawMouse.h=mTemp.h=helpRect.right+1;
  72.         else if (oldX>=helpRect.right)
  73.             RawMouse.h=mTemp.h=helpRect.left-1;
  74.         else
  75.             RawMouse.v=mTemp.v=helpRect.bottom+1;
  76.         CrsrNew = TRUE;
  77.     }
  78.     
  79.     oldX=RawMouse.h;
  80.     oldY=RawMouse.v;
  81.     
  82.     myVBL->vblCount = 1;
  83.     RestoreA4();
  84. }
  85.